class AddComplexIndex < ActiveRecord::Migration
  def self.up
    add_index :asin_infos, [:contents_type, :sales_rank, :author_id], :name => "index_asin_infos_on_ct_and_sr_and_aid"
    add_index :asin_infos, [:average_rating_rank, :contents_type, :sales_rank, :author_id], :name => "index_asin_infos_on_ar_and_ct_and_sr_and_aid"
    add_index :asin_infos, [:price_rank, :contents_type, :sales_rank, :author_id],:name => "index_asin_infos_on_pr_and_ct_and_sr_and_aid"
    add_index :asin_infos, [:number_ofpages_rank, :contents_type, :sales_rank, :author_id],:name => "index_asin_infos_on_npr_and_ct_and_sr_and_aid"
    add_index :asin_infos, [:publication_date_rank, :contents_type, :sales_rank, :author_id],:name => "index_asin_infos_on_pdr_and_ct_and_sr_and_aid"
    add_index :asin_infos, [:total_reviews_rank, :contents_type, :sales_rank, :author_id],:name => "index_asin_infos_on_trr_and_ct_and_sr_and_aid"

  end

  def self.down
    remove_index :asin_infos, :name => "index_asin_infos_on_ct_and_sr_and_aid"
    remove_index :asin_infos, :name => "index_asin_infos_on_ar_and_ct_and_sr_and_aid"
    remove_index :asin_infos, :name => "index_asin_infos_on_pr_and_ct_and_sr_and_aid"
    remove_index :asin_infos, :name => "index_asin_infos_on_npr_and_ct_and_sr_and_aid"
    remove_index :asin_infos, :name => "index_asin_infos_on_pdr_and_ct_and_sr_and_aid"
    remove_index :asin_infos, :name => "index_asin_infos_on_trr_and_ct_and_sr_and_aid"
  end
end
